package com.example.mydesignmodule.memo;

/**
 * @author tgw
 * @date 2021/3/3
 * @describe
 *
 * 数据需要被存储 的对象
 */
class GameAction {
    int level = 0;
    String levelName = "斗士";
    String gameMame = "凡人修真记";

    public void playGame() {
        System.out.println("开始玩游戏，当前等级：" + level + "--等级对应名称：" + levelName);
        level++;
        System.out.println("玩了一会后 升级了");
        System.out.println("当前等级：" + level);
    }


    public void quiteGame() {
        System.out.println("退出游戏");
        System.out.println("当前人物属性为：" + this.toString());
        level = 0;
        levelName = "斗士";
        gameMame = "凡人修真记";
    }

    /**
     * 创建游戏进度
     */
    public GameParam createGameMemo() {
        GameParam gameParam = new GameParam();
        gameParam.level = this.level;
        gameParam.levelName = this.levelName;
        gameParam.gameMame = this.gameMame;

        return gameParam;
    }

    /**
     * 恢复游戏进度
     */
    public void loadGameMemo(GameParam gameParam) {
        this.level = gameParam.level;
        this.levelName = gameParam.levelName;
        this.gameMame = gameParam.gameMame;
    }


    @Override
    public String toString() {
        return "GameAction{" +
                "level=" + level +
                ", levelName='" + levelName + '\'' +
                ", gameMame='" + gameMame + '\'' +
                '}';
    }
}
